package com.example.demo.entity;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 又菜又爱浪
 * 从information_schema库的columns表中查询特定表的字段信息
 */
public class TableColumnEntity implements Serializable {

    private static final long serialVersionUID = Objects.hashCode(TableColumnEntity.class);

    /**
     * 列名
     */
    private String columnName;
    /**
     * 列的类型
     */
    private String dataType;
    /**
     * 列的备注
     */
    private String columnComment;
    /**
     * 字段的最大长度，varchar等需要
     */
    private Long characterMaximumLength;

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getColumnComment() {
        return columnComment;
    }

    public void setColumnComment(String columnComment) {
        this.columnComment = columnComment;
    }

    public Long getCharacterMaximumLength() {
        return characterMaximumLength;
    }

    public void setCharacterMaximumLength(Long characterMaximumLength) {
        this.characterMaximumLength = characterMaximumLength;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof TableColumnEntity)) return false;
        TableColumnEntity that = (TableColumnEntity) o;
        return getColumnName().equals(that.getColumnName())
                && getDataType().equals(that.getDataType())
                && Objects.equals(getCharacterMaximumLength(), that.getCharacterMaximumLength());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getColumnName(), getDataType(), getCharacterMaximumLength());
    }
}
